package org.judo.test.controllers.admin;

import org.judo.components.uicontrol.ChoiceControl;
import org.judo.controller.PageController;
import org.judo.database.Database;
import org.judo.propertyobject.Prop;
import org.judo.propertyobject.PropertyObject;
import java.util.*;
import org.judo.controller.DefaultAction;
import org.judo.test.models.RoleStartPage;

public class RoleStartPageController extends PageController 
{
	private Database sysDB ;
	private String rolestartpageid ;
	private int roleid ;
	private String url ;
	private int rank ;
	private ArrayList results = new ArrayList();
	private int id ;

	@Prop private ChoiceControl chcRoles = new ChoiceControl();

	
	public void createRoleStartPage() throws Exception
	{
		chcRoles.define(sysDB.query("select roleName as display,roleId as code from Role order by roleName"));
	}
	
	public void detailRoleStartPage() throws Exception
	{
		PropertyObject obj = sysDB.find(parse("select * from ROLE_START_PAGE where ROLESTARTPAGEID = ${id}"));
		copyProps(obj);
	}

	public void setRolestartpageid(String rolestartpageid) 
	{
		this.rolestartpageid = rolestartpageid;
	}

	public String getRolestartpageid() 
	{
		return this.rolestartpageid;
	}

	public void setRoleid(int roleid) 
	{
		this.roleid = roleid;
	}

	public int getRoleid() 
	{
		return this.roleid;
	}

	public void setUrl(String url) 
	{
		this.url = url;
	}

	public String getUrl() 
	{
		return this.url;
	}

	public void setRank(int rank) 
	{
		this.rank = rank;
	}

	public int getRank() 
	{
		return this.rank;
	}

	public void insertRoleStartPage() throws Exception
	{
		showPage("/admin/Role_start_page_controller/display_role_start_page.do");
		RoleStartPage obj = new RoleStartPage();
		obj.copyProps(this);
		sysDB.insert("ROLE_START_PAGE",obj);
	}

	@DefaultAction
	public void displayRoleStartPage() throws Exception
	{
		results = (ArrayList)sysDB.query("select * from ROLE_START_PAGE");
	}

	public void setResults(ArrayList results) 
	{
		this.results = results;
	}

	public ArrayList getResults() 
	{
		return this.results;
	}

	public void editRoleStartPage() throws Exception
	{
		PropertyObject obj = sysDB.find(parse("select * from Role_start_page where ROLESTARTPAGEID = ${id}"));
		copyProps(obj);
	}

	public void setId(int id) 
	{
		this.id = id;
	}

	public int getId() 
	{
		return this.id;
	}

	public void updateRoleStartPage() throws Exception
	{
		showPage("/admin/Role_start_page_controller/display_role_start_page.do");
		RoleStartPage obj = (RoleStartPage)sysDB.find(RoleStartPage.class,id);
		obj.copyProps(this);
		sysDB.update("ROLE_START_PAGE",obj);
	}

	public void deleteRoleStartPage() throws Exception
	{
		showPage("/admin/Role_start_page_controller/display_role_start_page.do");
		sysDB.delete(this,"delete from ROLE_START_PAGE where ROLESTARTPAGEID = ${id}");
	}

}
